package com.risk.management.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web MVC配置
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * 静态资源处理
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/css/**")
                .addResourceLocations("classpath:/static/css/");
        registry.addResourceHandler("/js/**")
                .addResourceLocations("classpath:/static/js/");
        registry.addResourceHandler("/images/**")
                .addResourceLocations("classpath:/static/images/");
    }

    /**
     * 默认页面跳转
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // 为登录用户从系统内部返回首页时，确保跳转到dashboard
        registry.addViewController("/risk-management/index").setViewName("forward:/dashboard");
        registry.addViewController("/system-home").setViewName("forward:/dashboard");
    }
} 